package com.example.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.db.entity.UserInfo

/**
 * 用户信息的操作Dao,提供CRUD操作
 */
@Dao
interface UserInfoDao {
    @Insert
    //vararg表示可以接受多个实体,相当于Java的"..."
    suspend fun insertUserInfo(vararg user:UserInfo)//存多个实体
    @Delete
    suspend fun deleteUserInfo(vararg user:UserInfo)
    @Update
    suspend fun updateUserInfo(vararg user:UserInfo)
    //参数前面必须带冒号,表示接受
    @Query("select * from user_info where user_id =:userId")
    suspend fun queryUserInfo(userId:Int):UserInfo
    @Query("select * from user_info order by user_id")
    suspend fun queryAllUserInfo():List<UserInfo>

}